/*
 * Copyright (c) 2017-2021, Lindenis Tech. Ltd.
 * All rights reserved.
 *
 * File:
 *
 * Description:
 *
 * Author:
 *      xiaoshujun@lindeni.com
 *
 * Create Date:
 *      2021/04/07
 *
 * History:
 *
 */

#ifndef __LIND_TUNNEL_IOCTRL_DEFINE_H__
#define __LIND_TUNNEL_IOCTRL_DEFINE_H__

#ifdef __cplusplus
extern "C" {
#endif

typedef enum _LDT_IOCTRL_DEF_e {
    LDT_IOCTRL_INVALID                          = 0xFFFFFFFF,

    /*
     * event
     */
    LDT_IOCTRL_DEVICE_EVENT                     = 0x0001,   // device to client, refer to LDT_EVENT_e

    /*
     * ip camera a/v ioctrl
     */
    LDT_IOCTRL_IPC_BEGIN                        = 0x1000,
    LDT_IOCTRL_IPC_VIDEO_START_REQ              = 0x1000,   // start camera capture
    LDT_IOCTRL_IPC_VIDEO_START_RESP             = 0x1001,
    LDT_IOCTRL_IPC_VIDEO_STOP_REQ               = 0x1002,
    LDT_IOCTRL_IPC_VIDEO_STOP_RESP              = 0x1003,
    LDT_IOCTRL_IPC_AUDIO_START_REQ              = 0x1004,    // start mic capture
    LDT_IOCTRL_IPC_AUDIO_START_RESP             = 0x1005,
    LDT_IOCTRL_IPC_AUDIO_STOP_REQ               = 0x1006,
    LDT_IOCTRL_IPC_AUDIO_STOP_RESP              = 0x1007,

    LDT_IOCTRL_IPC_VIDEO_DECODE_START_REQ       = 0x1008,   // recv video from client
    LDT_IOCTRL_IPC_VIDEO_DECODE_START_RESP      = 0x1009,
    LDT_IOCTRL_IPC_VIDEO_DECODE_STOP_REQ        = 0x100A,
    LDT_IOCTRL_IPC_VIDEO_DECODE_STOP_RESP       = 0x100B,
    LDT_IOCTRL_IPC_SPEAKER_START_REQ            = 0x100C,   // recv audio from client
    LDT_IOCTRL_IPC_SPEAKER_START_RESP           = 0x100D,
    LDT_IOCTRL_IPC_SPEAKER_STOP_REQ             = 0x100E,
    LDT_IOCTRL_IPC_SPEAKER_STOP_RESP            = 0x100F,

    LDT_IOCTRL_IPC_GET_VIDEO_FMT_REQ            = 0x1010,
    LDT_IOCTRL_IPC_GET_VIDEO_FMT_RESP           = 0x1011,
    LDT_IOCTRL_IPC_SET_VIDEO_QUALITY_REQ        = 0x1012,
    LDT_IOCTRL_IPC_SET_VIDEO_QUALITY_RESP       = 0x1013,

    LDT_IOCTRL_IPC_GET_AUDIO_MIC_FMT_REQ        = 0x1014,
    LDT_IOCTRL_IPC_GET_AUDIO_MIC_FMT_RESP       = 0x1015,
    LDT_IOCTRL_IPC_SET_AUDIO_MIC_FMT_REQ        = 0x1016,   // not use, reserved
    LDT_IOCTRL_IPC_SET_AUDIO_MIC_FMT_RESP       = 0x1017,

    LDT_IOCTRL_IPC_GET_AUDIO_SPEAKER_FMT_REQ    = 0x101C,
    LDT_IOCTRL_IPC_GET_AUDIO_SPEAKER_FMT_RESP   = 0x101D,
    LDT_IOCTRL_IPC_SET_AUDIO_SPEAKER_FMT_REQ    = 0x101E,   // not use, reserved
    LDT_IOCTRL_IPC_SET_AUDIO_SPEAKER_FMT_RESP   = 0x101F,

    LDT_IOCTRL_IPC_GET_RECORD_MODE_REQ          = 0x1020,
    LDT_IOCTRL_IPC_GET_RECORD_MODE_RESP         = 0x1021,
    LDT_IOCTRL_IPC_SET_RECORD_MODE_REQ          = 0x1022,
    LDT_IOCTRL_IPC_SET_RECORD_MODE_RESP         = 0x1023,

    LDT_IOCTRL_IPC_MUSIC_CONTROL_REQ            = 0x1030,
    LDT_IOCTRL_IPC_MUSIC_CONTROL_RESP           = 0x1031,
    LDT_IOCTRL_IPC_MUSIC_EVENT                  = 0x1032,   // device to client

    LDT_IOCTRL_IPC_GET_VOLUME_REQ               = 0x1040,
    LDT_IOCTRL_IPC_GET_VOLUME_RESP              = 0x1041,
    LDT_IOCTRL_IPC_SET_VOLUME_REQ               = 0x1042,
    LDT_IOCTRL_IPC_SET_VOLUME_RESP              = 0x1043,

    /*
     * video playback
     */
    LDT_IOCTRL_IPC_GET_EVENT_LIST_REQ           = 0x1100,   // event defined by 'LDT_EVENT_e'
    LDT_IOCTRL_IPC_GET_EVENT_LIST_RESP          = 0x1101,

    /*
     * system ioctrl
     */
    LDT_IOCTRL_SYS_SET_PASSWORD_REQ             = 0x2000,
    LDT_IOCTRL_SYS_SET_PASSWORD_RESP            = 0x2001,

    LDT_IOCTRL_SYS_GET_DEVICE_INFO_REQ          = 0x2002,
    LDT_IOCTRL_SYS_GET_DEVICE_INFO_RESP         = 0x2003,

    LDT_IOCTRL_SYS_GET_WIFI_LIST_REQ            = 0x2004,
    LDT_IOCTRL_SYS_GET_WIFI_LIST_RESP           = 0x2005,
    LDT_IOCTRL_SYS_SET_WIFI_INFO_REQ            = 0x2006,
    LDT_IOCTRL_SYS_SET_WIFI_INFO_RESP           = 0x2007,

    LDT_IOCTRL_SYS_GET_NET_INFO_REQ             = 0x2008,
    LDT_IOCTRL_SYS_GET_NET_INFO_RESP            = 0x2009,

    LDT_IOCTRL_SYS_SET_TIME_REQ                 = 0x200C,
    LDT_IOCTRL_SYS_SET_TIME_RESP                = 0x200D,
    LDT_IOCTRL_SYS_UPDATE_NTP_REQ               = 0x200E,
    LDT_IOCTRL_SYS_UPDATE_NTP_RESP              = 0x200F,

    LDT_IOCTRL_SYS_CHECK_OTA_REQ                = 0x2100,
    LDT_IOCTRL_SYS_CHECK_OTA_RESP               = 0x2101,
    LDT_IOCTRL_SYS_START_OTA_REQ                = 0x2102,
    LDT_IOCTRL_SYS_START_OTA_RESP               = 0x2103,

    /*
     * peripheral device ioctrl
     */
    LDT_IOCTRL_SET_PTZ_REQ                      = 0x8000,    // Pan/Tilt/Zoom
    LDT_IOCTRL_SET_PTZ_RESP                     = 0x8001,

    LDT_IOCTRL_GET_IR_MODE_REQ                  = 0x8004,
    LDT_IOCTRL_GET_IR_MODE_RESP                 = 0x8005,
    LDT_IOCTRL_SET_IR_MODE_REQ                  = 0x8006,
    LDT_IOCTRL_SET_IR_MODE_RESP                 = 0x8007,

    LDT_IOCTRL_GET_DHT_SENSOR_CURRENT_REQ       = 0x8008,    // Digital Humidity & Temperature
    LDT_IOCTRL_GET_DHT_SENSOR_CURRENT_RESP      = 0x8009,
    LDT_IOCTRL_GET_DHT_SENSOR_HISTORY_REQ       = 0x800A,
    LDT_IOCTRL_GET_DHT_SENSOR_HISTORY_RESP      = 0x800B,
    LDT_IOCTRL_SET_ALARM_TEMPERATURE_REQ        = 0x800C,
    LDT_IOCTRL_SET_ALARM_TEMPERATURE_RESP       = 0x800D,
    LDT_IOCTRL_GET_ALARM_TEMPERATURE_REQ        = 0x800E,
    LDT_IOCTRL_GET_ALARM_TEMPERATURE_RESP       = 0x800F,
    LDT_IOCTRL_SET_ALARM_HUMIDITY_REQ           = 0x8010,
    LDT_IOCTRL_SET_ALARM_HUMIDITY_RESP          = 0x8011,
    LDT_IOCTRL_GET_ALARM_HUMIDITY_REQ           = 0x8012,
    LDT_IOCTRL_GET_ALARM_HUMIDITY_RESP          = 0x8013,

    LDT_IOCTRL_SET_ALARM_SOUND_REQ              = 0x8100,
    LDT_IOCTRL_SET_ALARM_SOUND_RESP             = 0x8101,
    LDT_IOCTRL_GET_ALARM_SOUND_REQ              = 0x8102,
    LDT_IOCTRL_GET_ALARM_SOUND_RESP             = 0x8103,

    /*
     * reserved for user extended ioctrl
     */
    LDT_IOCTRL_USER_BEGIN                       = 0xA000,
    LDT_IOCTRL_USER_END                         = 0xFFFE,
} LDT_IOCTRL_DEF_e;

/**
 * define common request/response structure
 */
typedef struct _ldt_ioctrl_request_t
{
    int8_t      reserved[4];
} ldt_ioctrl_request_t;

typedef struct _ldt_ioctrl_response_t
{
    int32_t     result;         // 0: sucess, -1: failed
    int8_t      reserved[4];
} ldt_ioctrl_response_t;

/**
 * LDT_IOCTRL_DEVICE_EVENT
 */
typedef enum
{
    LDT_EVENT_ALL                   = 0x0,
    LDT_EVENT_EMERGENCY             = 0x1,
    LDT_EVENT_FULLTIME_RECORDING    = 0x2,

    LDT_EVENT_SOUND_BASE            = 0x10,
    LDT_EVENT_CRY_START             = LDT_EVENT_SOUND_BASE + 0x1,       // 0x11
    LDT_EVENT_CRT_STOP              = LDT_EVENT_SOUND_BASE + 0x2,       // 0x12
    LDT_EVENT_SOUND_TRIGGER         = LDT_EVENT_SOUND_BASE + 0x3,       // 0x13
    LDT_EVENT_CONTINUOUS_START      = LDT_EVENT_SOUND_BASE + 0x4,       // 0x14
    LDT_EVENT_CONTINUOUS_STOP       = LDT_EVENT_SOUND_BASE + 0x5,       // 0x15
    LDT_EVENT_SOUND_DB              = LDT_EVENT_SOUND_BASE + 0x6,       // 0x16
    LDT_EVENT_SOUND_END             = 0x1F,

    LDT_EVENT_DHT_BASE              = 0x20,
    LDT_EVENT_DHT_TEMP_LOW          = LDT_EVENT_DHT_BASE + 0x1,         // 0x21
    LDT_EVENT_DHT_TEMP_HIGH         = LDT_EVENT_DHT_BASE + 0x2,         // 0x22
    LDT_EVENT_DHT_HUMI_LOW          = LDT_EVENT_DHT_BASE + 0x4,         // 0x24
    LDT_EVENT_DHT_HUMI_HIGH         = LDT_EVENT_DHT_BASE + 0x8,         // 0x28
    LDT_EVENT_DHT_TL_HL             = LDT_EVENT_DHT_BASE + 0x1 + 0x4,   // 0x25
    LDT_EVENT_DHT_TL_HH             = LDT_EVENT_DHT_BASE + 0x1 + 0x8,   // 0x29
    LDT_EVENT_DHT_TH_HL             = LDT_EVENT_DHT_BASE + 0x2 + 0x4,   // 0x26
    LDT_EVENT_DHT_TH_HH             = LDT_EVENT_DHT_BASE + 0x2 + 0x8,   // 0x2a
    LDT_EVENT_DHT_END               = 0x2F,

    LDT_EVENT_IR_BASE               = 0x30,
    LDT_EVENT_IR_ON                 = LDT_EVENT_IR_BASE + 0x1,          // 0x31
    LDT_EVENT_IR_OFF                = LDT_EVENT_IR_BASE + 0x2,          // 0x32
    LDT_EVENT_IR_END                = 0x3F,

    LDT_EVENT_BB_BASE               = 0x40,
    LDT_EVENT_BB_FALLSLEEP          = LDT_EVENT_BB_BASE + 0x1,          // 0x41
    LDT_EVENT_BB_AWAKE              = LDT_EVENT_BB_BASE + 0x2,          // 0x42
    LDT_EVENT_BB_APNEA              = LDT_EVENT_BB_BASE + 0x3,          // 0x43
    LDT_EVENT_BB_HIGHBPM            = LDT_EVENT_BB_BASE + 0x4,          // 0x44
    LDT_EVENT_BB_LOWBPM             = LDT_EVENT_BB_BASE + 0x5,          // 0x45
    LDT_EVENT_BB_HIGHRPM            = LDT_EVENT_BB_BASE + 0x6,          // 0x46
    LDT_EVENT_BB_LOWRPM             = LDT_EVENT_BB_BASE + 0x7,          // 0x47
    LDT_EVENT_BB_MOTION             = LDT_EVENT_BB_BASE + 0x8,          // 0x48
    LDT_EVENT_BB_END                = 0x4F,

    LDT_EVENT_MOTION_BASE           = 0x50,
    LDT_EVENT_MOTION_TRIGGER        = LDT_EVENT_MOTION_BASE + 0X1,      // 0X51

    LDT_EVENT_MAX                   = 0xFFFF,
} LDT_EVENT_e;

typedef struct
{
    int32_t     type;   // refer to LDT_EVENT_e
    int8_t      reserved[8];
} ldt_ioctrl_event_t;

typedef struct
{
    int32_t     type;   // for event: LDT_EVENT_DHT_XXX
    float       temperature;
    float       humidity;
} ldt_ioctrl_dht_event_t;

typedef struct
{
    int32_t     type;   // for event: LDT_EVENT_DHT_XXX
    int32_t     db;
    uint32_t    tm_utc;
} ldt_ioctrl_sound_event_t;

/**
 * LDT_IOCTRL_IPC_VIDEO_START_REQ
 * LDT_IOCTRL_IPC_VIDEO_START_RESP
 * LDT_IOCTRL_IPC_VIDEO_STOP_REQ
 * LDT_IOCTRL_IPC_VIDEO_STOP_RESP
 */
typedef struct
{
    uint32_t    camera_id;
    int8_t      reserved[4];    // not used
} ldt_ioctrl_video_start_req_t, ldt_ioctrl_video_stop_req_t;

typedef struct _ldt_ioctrl_response_t ldt_ioctrl_video_start_resp_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_video_stop_resp_t;

/**
 * LDT_IOCTRL_IPC_AUDIO_START_REQ
 * LDT_IOCTRL_IPC_AUDIO_START_RESP
 * LDT_IOCTRL_IPC_AUDIO_STOP_REQ
 * LDT_IOCTRL_IPC_AUDIO_STOP_RESP
 */
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_audio_start_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_audio_start_resp_t;

typedef struct _ldt_ioctrl_request_t ldt_ioctrl_audio_stop_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_audio_stop_resp_t;

/**
 * LDT_IOCTRL_IPC_SPEAKER_START_REQ
 * LDT_IOCTRL_IPC_SPEAKER_START_RESP
 * LDT_IOCTRL_IPC_SPEAKER_STOP_REQ
 * LDT_IOCTRL_IPC_SPEAKER_STOP_RESP
 */
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_speaker_start_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_speaker_start_resp_t;

typedef struct _ldt_ioctrl_request_t ldt_ioctrl_speaker_stop_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_speaker_stop_resp_t;

/**
 * LDT_IOCTRL_IPC_GET_VIDEO_FMT_REQ            = 0x1010,
 * LDT_IOCTRL_IPC_GET_VIDEO_FMT_RESP           = 0x1011,
 * LDT_IOCTRL_IPC_SET_VIDEO_QUALITY_REQ        = 0x1012,
 * LDT_IOCTRL_IPC_SET_VIDEO_QUALITY_RESP       = 0x1013,
 */
typedef struct
{
    uint32_t    camera_id;
    int8_t      reserved[4];
} ldt_ioctrl_get_vfmt_req_t;

typedef struct
{
    uint32_t    camera_id;
    uint32_t    codec;          // refer to LDT_CODEC_ID_e
                                // only valid for 'ldt_ioctrl_get_vfmt_resp_t'
    uint32_t    quality;        // refer to LDT_VIDEO_QUALITY_e
                                // valid for both 'get' and 'set'
                                // get current quality or switch to new quality
    uint32_t    width;          // width of video encode
                                // only valid for 'ldt_ioctrl_get_vfmt_resp_t'
                                // if 'quality' is equal to 'LDT_VIDEO_QUALITY_AUTO', 'width' may change as the network
    uint32_t    height;         // height of video encode
                                // only valid for 'ldt_ioctrl_get_vfmt_resp_t'
                                // if 'quality' is equal to  'LDT_VIDEO_QUALITY_AUTO', 'height' may change as the network
    int8_t      reserved[4];    // not used
} ldt_ioctrl_get_vfmt_resp_t;

typedef struct
{
    uint32_t    camera_id;
    uint32_t    quality;        // refer to LDT_VIDEO_QUALITY_e
    int8_t      reserved[4];    // not used
} ldt_ioctrl_set_vquality_req_t;

typedef struct _ldt_ioctrl_response_t ldt_ioctrl_set_vquality_resp_t;

/**
 * LDT_IOCTRL_IPC_GET_AUDIO_MIC_FMT_REQ
 * LDT_IOCTRL_IPC_GET_AUDIO_MIC_FMT_RESP
 * LDT_IOCTRL_IPC_GET_AUDIO_SPEAKER_FMT_REQ
 * LDT_IOCTRL_IPC_GET_AUDIO_SPEAKER_FMT_RESP
 */
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_get_afmt_mic_req_t;
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_get_afmt_spk_req_t;
typedef struct
{
    uint32_t    codec;          // refer to LDT_CODEC_ID_e
    uint32_t    sample_rate;    // refer to LDT_AUDIO_SAMPLE_RATE_e
    uint32_t    bits;           // refer to LDT_AUDIO_BITS_e
    uint32_t    channels;       // refer to LDT_AUDIO_CHANNEL_e
    int8_t      reserved[4];    // not used
} ldt_ioctrl_get_afmt_mic_resp_t, ldt_ioctrl_get_afmt_spk_resp_t;

typedef enum
{
    LDT_CODEC_VIDEO_H264            = 0x00,
    LDT_CODEC_VIDEO_H265            = 0x01,

    LDT_CODEC_AUDIO_PCM             = 0x80,
    LDT_CODEC_AUDIO_AAC_ADTS        = 0x81,
    LDT_CODEC_AUDIO_MP3             = 0x83,
} LDT_CODEC_ID_e;

typedef enum
{
    LDT_FRAME_FORMAT_RAW            = 0x0,  // PCM/YUV/RGB ...
    LDT_FRAME_FORMAT_ES             = 0x1,  // B/P-frame
    LDT_FRAME_FORMAT_ES_I           = 0x2,  // I-frame(with H264/H265 spspps)
} LDT_FRAME_FORMAT_e;

typedef enum
{
    LDT_AUDIO_SAMPLE_8K             = 8000,
    LDT_AUDIO_SAMPLE_16K            = 16000,
    LDT_AUDIO_SAMPLE_22K            = 22050,
    LDT_AUDIO_SAMPLE_32K            = 32000,
    LDT_AUDIO_SAMPLE_44K            = 44100,
    LDT_AUDIO_SAMPLE_48K            = 48000,
} LDT_AUDIO_SAMPLE_RATE_e;

typedef enum
{
    LDT_AUDIO_BITS_8                = 8,
    LDT_AUDIO_BITS_16               = 16,
    LDT_AUDIO_BITS_24               = 24,
    LDT_AUDIO_BITS_32               = 32,
} LDT_AUDIO_BITS_e;

typedef enum
{
    LDT_AUDIO_CHANNEL_MONO          = 1,
    LDT_AUDIO_CHANNEL_STERO         = 2,
} LDT_AUDIO_CHANNEL_e;

/**
 * LDT_IOCTRL_IPC_GET_RECORD_MODE_REQ
 * LDT_IOCTRL_IPC_GET_RECORD_MODE_RESP
 * LDT_IOCTRL_IPC_SET_RECORD_MODE_REQ
 * LDT_IOCTRL_IPC_SET_RECORD_MODE_RESP
 */
typedef struct
{
    uint32_t    mode;           // refer to LDT_RECORD_MODE_e
    uint32_t    codec;          // refer to LDT_CODEC_ID_e
                                // only valid for 'ldt_ioctrl_get_record_resp_t'
    uint32_t    quality;        // refer to LDT_VIDEO_QUALITY_e
    int8_t      reserved[4];    // not used
} ldt_ioctrl_get_rec_mode_resp_t, ldt_ioctrl_set_rec_mode_req_t;

typedef struct _ldt_ioctrl_request_t ldt_ioctrl_get_rec_mode_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_set_rec_mode_resp_t;

typedef enum
{
    LDT_RECORD_MODE_OFF             = 0x00,
    LDT_RECORD_MODE_FULLTIME        = 0x01,
    LDT_RECORD_MODE_ALARM           = 0x02,
} LDT_RECORD_MODE_e;

typedef enum
{
    /**
     * Device define 'HIGH/MIDDLE/LOW' to a specific video size and bitrate
     */
    LDT_VIDEO_QUALITY_HIGH          = 0x01, // such as: 1920x1080 @ 2Mbps
    LDT_VIDEO_QUALITY_MIDDLE        = 0x02, // such as: 1280x 720 @ 1Mbps
    LDT_VIDEO_QUALITY_LOW           = 0x03, // such as:  640x 480 @ 500Kbps

    /**
     * Dynamic Adaptive Stream
     * such as: 'LDT_VIDEO_QUALITY_AUTO' means the devices dynamic change the video size or bitrate
     * such as: 'LDT_VIDEO_QUALITY_AUTO | LDT_VIDEO_QUALITY_HIGH' means 1920x1080 @ Dynamic Adaptive Bitrate
     */
    LDT_VIDEO_QUALITY_AUTO          = 0x10,
} LDT_VIDEO_QUALITY_e;

/**
 * LDT_IOCTRL_IPC_MUSIC_CONTROL_REQ            = 0x1030,
 * LDT_IOCTRL_IPC_MUSIC_CONTROL_RESP           = 0x1031,
 * LDT_IOCTRL_IPC_MUSIC_EVENT                  = 0x1032,
 */
typedef enum
{
    LDT_MUSIC_CTRL_IDLE             = 0x00, // do not use this command
    LDT_MUSIC_CTRL_START            = 0x01,
    LDT_MUSIC_CTRL_STOP             = 0x02,
    LDT_MUSIC_CTRL_PAUSE            = 0x03,
    LDT_MUSIC_CTRL_RESUME           = 0x04,
    LDT_MUSIC_CTRL_SEEK             = 0x05,

    /**
     * commands to get music inforation.
     */
    LDT_MUSIC_CTRL_GET_STATUS       = 0x40, // refer to LDT_MUSIC_STATUS_e
    LDT_MUSIC_CTRL_SET_PLAYMODE     = 0x41, // refer to LDT_MUSIC_PLAYMODE_e

    /**
     * commands below are from device to client.
     */
    LDT_MUSIC_CTRL_EOF              = 0x80, // playback end
    LDT_MUSIC_CTRL_POSTION          = 0x81, // current playback postion, unit: second
} LDT_MUSIC_CTRL_e;

typedef enum
{
    LDT_MUSIC_STATUS_IDLE           = 0x00,
    LDT_MUSIC_STATUS_PREPARE        = 0x01,
    LDT_MUSIC_STATUS_START          = 0x02,
    LDT_MUSIC_STATUS_PAUSE          = 0x04,
    LDT_MUSIC_STATUS_STOP           = 0x08,
} LDT_MUSIC_STATUS_e;

typedef enum
{
    LDT_MUSIC_PLAYMODE_INVALID      = 0x00,
    LDT_MUSIC_PLAYMODE_SINGLE       = 0x01,
    LDT_MUSIC_PLAYMODE_SINGLE_LOOP  = 0x02,
    LDT_MUSIC_PLAYMODE_LIST_LOOP    = 0x03,
} LDT_MUSIC_PLAYMODE_e;

typedef struct
{
    int32_t     command;        // refer to LDT_MUSIC_CTRL_e
    int32_t     id;             // only for LDT_MUSIC_CTRL_START, 'id' or 'url' choose one.
                                // 'id' is the number of pre-installed music files
                                // valid if 'id' > 0, then donot care 'url'
    char        url[512];       // only for LDT_MUSIC_CTRL_START, 'id' or 'url' choose one.
                                // the url will playback.
                                // valid only when 'id' <= 0
                                // such as: "/mnt/extsd/1.mp3",
                                //       or "http://aod.cos.tx.xmcdn.com/group3/M03/AE/29/wKgDslLCmAaSzKXZAFbLuvsW4ds663.mp3"
    char        name[128];      // only for LDT_MUSIC_CTRL_START
                                // the short name of this music, it will return to app by command 'LDT_MUSIC_CTRL_GET_STATUS'
                                // must be set '0' if there is no short name.
    int32_t     playmode;       // refer to LDT_MUSIC_PLAYMODE_e
    int32_t     seek_tm;        // only for LDT_MUSIC_CTRL_START & LDT_MUSIC_CTRL_SEEK
                                // unit: seconds
    int8_t      reserved[4];
} ldt_ioctrl_music_req_t;

typedef struct
{
    int32_t     command;        // refer to LDT_MUSIC_CTRL_e
    int32_t     result;         // 0: success; otherwise: failed.
    int32_t     duration;       // the duration of music, unit: seconds
    int32_t     position;       // current playback postion, unit: second
    int32_t     status;         // refer to LDT_MUSIC_STATUS_e
    char        name[128];      // the short name of this music, set by app
    int32_t     playmode;       // refer to LDT_MUSIC_PLAYMODE_e
    int8_t      reserved[4];
} ldt_ioctrl_music_resp_t, ldt_ioctrl_music_event_t;

/**
 * LDT_IOCTRL_IPC_GET_VOLUME_REQ               = 0x1040,
 * LDT_IOCTRL_IPC_GET_VOLUME_RESP              = 0x1041,
 * LDT_IOCTRL_IPC_SET_VOLUME_REQ               = 0x1042,
 * LDT_IOCTRL_IPC_SET_VOLUME_RESP              = 0x1043,
 */
typedef struct
{
    int32_t     volume;         // [0, 10], 0: mute, 10: max volume
    int8_t      reserved[4];    // not used
} ldt_ioctrl_set_volume_req_t, ldt_ioctrl_get_volume_resp_t;

typedef struct _ldt_ioctrl_request_t ldt_ioctrl_get_volume_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_set_volume_resp_t;


/**
 * LDT_IOCTRL_SYS_GET_DEVICE_INFO_REQ
 * LDT_IOCTRL_SYS_GET_DEVICE_INFO_RESP
 */
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_get_devinfo_req_t;

typedef struct
{
    char        vendor[32];
    char        product[32];
    char        model[32];
    uint32_t    version;        // ex. v1.0.0.0 => 0x01000000
                                //     v1.1.1.0 => 0x01010100

    /*
     * extern SD card
     */
    uint32_t    total;          // size in MB, 0: no sdcard inserted.
    uint32_t    free;           // size in MB

    int8_t      reserved[4];    // not used
} ldt_ioctrl_get_devinfo_resp_t;

/**
 * LDT_IOCTRL_SET_PTZ_REQ
 * LDT_IOCTRL_SET_PTZ_RESP
 */
typedef struct
{
    uint32_t    control;        // refer to LDT_PTZ_COMMAND_e
    uint32_t    speed;          // for turnning, not used now
    uint32_t    zoom_ratio;     // for zoom in/out set a respect ratio.
                                // such as: 100: 1x, 150: 1.5x, ...
                                // range: [100, 400]
                                // If 'zoom_ratio' is not equal to '0', LDT_PTZ_ZOOM_IN and
                                //      LDT_PTZ_ZOOM_OUT have the same funtion.
    uint32_t    zoom_step;      // If 'zoom_ratio' is equal to '0', app should set 'zoom_step'.
                                //      LDT_PTZ_ZOOM_IN/OUT means zoom in/out with a scale step.
                                // such as: 10: 10%
    int8_t      reserved[4];    // not used
} ldt_ioctrl_set_ptz_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_set_ptz_resp_t;

typedef enum
{
    LDT_PTZ_STOP                    = 0x00,
    LDT_PTZ_LEFT                    = 0x01,
    LDT_PTZ_RIGHT                   = 0x02,
    LDT_PTZ_UP                      = 0x03,
    LDT_PTZ_DOWN                    = 0x04,
    LDT_PTZ_RESET_CENTER            = 0x09,

    LDT_PTZ_FLIP                    = 0x20,
    LDT_PTZ_MIRROR                  = 0x21,
    LDT_PTZ_ZOOM_IN                 = 0x22,
    LDT_PTZ_ZOOM_OUT                = 0x23,
} LDT_PTZ_COMMAND_e;

/**
 * LDT_IOCTRL_SYS_SET_TIME_REQ
 * LDT_IOCTRL_SYS_SET_TIME_RESP
 */
typedef struct
{
    int32_t     utc;            // in seconds
    int8_t      tz;             // [-12, +12]
                                //  0: GMT(Greenwich Mean Time), default value.
                                // +8: CST(China Standard Time)
                                // -8: PST(Pacific Daylight Time)
    int8_t      reserved[3];    // not used
} ldt_ioctrl_set_time_req_t;

typedef struct _ldt_ioctrl_response_t ldt_ioctrl_set_time_resp_t;

/**
 * LDT_IOCTRL_SYS_UPDATE_NTP_REQ
 * LDT_IOCTRL_SYS_UPDATE_NTP_RESP
 */
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_update_ntp_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_update_ntp_resp_t;

/**
 * LDT_IOCTRL_SYS_CHECK_OTA_REQ
 * LDT_IOCTRL_SYS_CHECK_OTA_RESP
 */
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_check_ota_req_t;

typedef struct
{
    int32_t result;             // 0: already be newest version
                                // 1: there is a newer version
    uint32_t version;           // such as: v1.0.0
    char description[1000];     // the description of new version
                                // valid when 'result' is 1
    int8_t reserved[4];
} ldt_ioctrl_check_ota_resp_t;

/**
 * LDT_IOCTRL_SYS_START_OTA_REQ
 * LDT_IOCTRL_SYS_START_OTA_RESP
 */
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_start_ota_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_start_ota_resp_t;

/**
 * LDT_IOCTRL_GET_IR_MODE_REQ
 * LDT_IOCTRL_GET_IR_MODE_RESP
 * LDT_IOCTRL_SET_IR_MODE_REQ
 * LDT_IOCTRL_SET_IR_MODE_RESP
 */
typedef struct
{
    int32_t     mode;           // 0: off, 1: on, 2: auto, <0: failed
    int8_t      reserved[4];    // not used
} ldt_ioctrl_set_ir_mode_req_t, ldt_ioctrl_get_ir_mode_resp_t;

typedef struct _ldt_ioctrl_request_t ldt_ioctrl_get_ir_mode_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_set_ir_mode_resp_t;

/**
 * LDT_IOCTRL_GET_DHT_SENSOR_CURRENT_REQ
 * LDT_IOCTRL_GET_DHT_SENSOR_CURRENT_RESP
 */
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_get_dht_cur_req_t;
typedef struct
{
    uint32_t    gtm_utc;
    float       temperature;
    float       humidity;
} ldt_ioctrl_get_dht_cur_resp_t, ldt_dht_sensor_t;

/**
 * LDT_IOCTRL_GET_DHT_SENSOR_HISTORY_REQ
 * LDT_IOCTRL_GET_DHT_SENSOR_HISTORY_RESP
 */
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_get_dht_hist_req_t;
typedef struct
{
    uint32_t    total;          // total sensor data count
    uint8_t     index;          // package index
    uint8_t     endflag;        // 1 means this package is the last one.
    uint8_t     count;          // how much sensor data in this package
    uint8_t     reason;         // 0: no error, if 'total' is '0', the reason tell you why.
                                // 1: no SD Card
    ldt_dht_sensor_t    data[1];
} ldt_ioctrl_get_dht_hist_resp_t;

/**
 * LDT_IOCTRL_SET_ALARM_TEMPERATURE_REQ        = 0x800C,
 * LDT_IOCTRL_SET_ALARM_TEMPERATURE_RESP       = 0x800D,
 * LDT_IOCTRL_GET_ALARM_TEMPERATURE_REQ        = 0x800E,
 * LDT_IOCTRL_GET_ALARM_TEMPERATURE_RESP       = 0x800F,
 */
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_get_alarm_temp_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_set_alarm_temp_resp_t;
typedef struct
{
    int8_t mode;                // 0: off, 1: on
    int8_t temperature_min;     // range: [-40, 50], degree Centigrade
    int8_t temperature_max;     // range: [-40, 50], degree Centigrade
    int8_t unit;                // 0: degree Centigrade, 1: degree Fahrenheit
    int8_t reserved[4];
} ldt_ioctrl_set_alarm_temp_req_t, ldt_ioctrl_get_alarm_temp_resp_t;

/**
 * LDT_IOCTRL_SET_ALARM_HUMIDITY_REQ           = 0x8010,
 * LDT_IOCTRL_SET_ALARM_HUMIDITY_RESP          = 0x8011,
 * LDT_IOCTRL_GET_ALARM_HUMIDITY_REQ           = 0x8012,
 * LDT_IOCTRL_GET_ALARM_HUMIDITY_RESP          = 0x8013,
 */
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_get_alarm_humi_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_set_alarm_humi_resp_t;
typedef struct
{
    int8_t mode;             // 0: off, 1: on
    int8_t humidity_min;     // range: [0, 100]
    int8_t humidity_max;     // range: [0, 100]
    int8_t reserved[1];
} ldt_ioctrl_set_alarm_humi_req_t, ldt_ioctrl_get_alarm_humi_resp_t;

/**
 * LDT_IOCTRL_SET_ALARM_SOUND_REQ              = 0x8100,
 * LDT_IOCTRL_SET_ALARM_SOUND_RESP             = 0x8101,
 * LDT_IOCTRL_GET_ALARM_SOUND_REQ              = 0x8102,
 * LDT_IOCTRL_GET_ALARM_SOUND_RESP             = 0x8103,
 */
typedef struct _ldt_ioctrl_request_t ldt_ioctrl_get_alarm_sound_req_t;
typedef struct _ldt_ioctrl_response_t ldt_ioctrl_set_alarm_sound_resp_t;
typedef struct
{
    int8_t mode;            // 0: off, 1: on
    int8_t sensitivity;     // range: [0, 100]
    int8_t reserved[2];
} ldt_ioctrl_set_alarm_sound_req_t, ldt_ioctrl_get_alarm_sound_resp_t;

#ifdef __cplusplus
}
#endif

#endif  // __LIND_TUNNEL_IOCTRL_DEFINE_H__


